<?php
class InfoAction extends CommonAction{
	private $userinfo;
	function _initialize(){
		$user = $this->getLoginUser();
		if(!$user){
			$this->redirect('User/login');
		}
		$Userinfo = D("userinfo");
		$info = $Userinfo->where(array('user' => $this->getLoginUser()))->find();
		if(!$info){
			$infoid = $Userinfo->add(array('user' => $this->getLoginUser()));
			$info = array('id' => $infoid,'user' => $this->getLoginUser());
		}
		$this->userinfo = $info;
	}
	
	public function index(){
		$Userinfo = D("userinfo");
		$info = $Userinfo->where(array('user' => $this->getLoginUser()))->find();
		
		$arr = array(
			'baseinfo' => 0,
			'unitinfo' => 0,

		);
		//判断资料完整性

        if($info['name'] && $info['usercard'] && $info['huzhao'] && $info['cardphoto_1'] && $info['cardphoto_2'] && $info['cardphoto_3'] && $info['cardphoto_4']){
            $arr['baseinfo'] = 1;
        }

        if($info['dwname'] && $info['dwaddess_ssq'] && $info['dwaddess_more'] && $info['position'] && $info['workyears'] && $info['dwysr'] && $info['addess_ssq'] && $info['addess_more']
            && $info['tj_name'] && $info['tj_mobile'] && $info['real_name'] && $info['sex']){
            $arr['unitinfo'] = 1;
        }

		$this->info = $arr;
		$this->display();
	}
	
	//身份信息
	//姓名、身份证号码、住址
	public function baseinfo(){
		if(IS_POST){
			$data = array('status' => 0,'msg' => '未知错误');
			$Userinfo = D("userinfo");
            $status = $Userinfo->where(array('user' => $this->getLoginUser()))->save($_POST);
            if(is_int($status)){
                $u = D("user")->where(array('phone' => $this->getLoginUser()))->save(array('truename'=>$_POST['name']));
                    if(!is_int($u)){
                        $data['msg'] = "保存失败";
                }else{
                    $data['status'] = 1;
                }
                $this->ajaxReturn($data);
                exit;
            }
		}
		$this->assign("userinfo",$this->userinfo);
		$this->display();
	}

    //企业信息的基本信息
    public function qybaseinfo(){
        $isexist = D("qybaseinfo")->where(array('user' => $this->getLoginUser()))->find();
        if(IS_POST){
            $data = array('status' => 0,'msg' => '未知错误');
            $_POST['user'] = $this->getLoginUser();
            if($isexist){
                $status = D("qybaseinfo")->where(array('user' => $this->getLoginUser()))->save($_POST);
            }else{
                $status = D("qybaseinfo")->add(I('post.'));
            }

            if($status){
                $data['msg'] = "保存成功";
                $data['status'] = 1;
                $this->ajaxReturn($data);
                exit;
            }else{
                $data['msg'] = "保存失败";
                $data['status'] = 0;
                $this->ajaxReturn($data);
                exit;
            }
        }

        $this->assign("userinfo",$isexist);
        $this->display();
    }

	//单位信息
	public function unitinfo(){
		
		if(IS_POST){
			$data = array('status' => 0,'msg' => '未知错误');
			$Userinfo = D("userinfo");
				$order = D("order");
			 $tduo = $order->where(array('user' => $this->getLoginUser(),'status' =>2))->count();
				
			if(session('money')!=''){
				$url=U('Order/daikuan');
			}else{
				$url=U('Info/shanginfo');
			}
			$status = $Userinfo->where(array('user' => $this->getLoginUser()))->save(I('post.'));
			if($status===false){				
				$data['errmsg'] = "保存失败，你没有修改任何资料";
			}else{
				$data['status'] = 1;
				$data['url']=$url;
				$data['errmsg'] = "保存成功！";
			}

			$this->ajaxReturn($data);
			exit;
		}
		$this->assign("inf",$this->userinfo);

		$this->display();
	}

    //企业的资料信息
    public function qyunitinfo(){
        $qyunitinfo = D("qyunitinfo");
        $isexist = $qyunitinfo->where(array('user' => $this->getLoginUser()))->find();

        if(IS_POST){
            $data = array('status' => 0,'msg' => '未知错误');
            $qyunitinfo = D("qyunitinfo");

            if(session('money')!=''){
                $url=U('Order/daikuan');
            }else{
                $url=U('Info/qiyeinfo');
            }
            $status = $qyunitinfo->where(array('user' => $this->getLoginUser()))->save(I('post.'));
            if($status===false){
                $data['errmsg'] = "保存失败，你没有修改任何资料";
            }else{
                $data['status'] = 1;
                $data['url']=$url;
                $data['errmsg'] = "保存成功！";
            }

            $this->ajaxReturn($data);
            exit;
        }
        $this->assign("inf",$isexist);
        $this->display();
    }





public function indexadd(){
		header('Content-Type:text/html;charset=utf-8');
		
		$data=array('shenghuofei' => $_POST['shenghuofei'],'xueli' => $_POST['shenghuofei']);
		var_dump($data);exit();
				if ($userinfo=M('userinfo')->where(array('user' => $this->getLoginUser()))->save($data)){
					echo '<script>alert("提交成功")</script>';
				}else{
					echo '<script>alert("提交失败")</script>';
				}
			
	   }
		

	//银行卡信息
	public function bankinfo(){
		$oid=$_GET['oid'];
		if(IS_POST){
			$data = array('status' => 0,'msg' => '未知错误');
			$bankcard = I("bankcard",0,'trim');
			if(strlen($bankcard) < 16 || strlen($bankcard) > 20){
				$data['msg'] = "不是有效的银行卡号!";
			}else{
				$Userinfo = D("userinfo");
				
				$order = D("order");
				$tduo = $order->where(array('user' => $this->getLoginUser(),'status' =>2))->count();
	
							
			
				$status = $Userinfo->where(array('user' => $this->getLoginUser()))->save($_POST);
				if($status===false){
					$data['msg'] = "保存失败，你没有修改任何资料";
				}else{
					$data['status'] = 1;
				}
			
			}
			$this->ajaxReturn($data);
			exit;
		}
		$this->assign('oid',$oid);
		$this->assign("userinfo",$this->userinfo);
		$this->display();
	}
	
	//芝麻信用授权确认
	public function zhimastepone(){
		$userinfo = $this->userinfo;
		if($userinfo['alipay']){
			$this->redirect('Info/index');
		}
		$this->display();
	}
	
	//芝麻信用授权
	public function zhimasteptwo(){
		$userinfo = $this->userinfo;
		if($userinfo['alipay']){
			$this->redirect('Info/index');
		}
		if(IS_POST){
			$data = array('status' => 0,'msg' => '未知错误');
			$code = I("code",'','trim');
			if(strlen($code) != 6){
				$data['msg'] = "短信验证码输入有误";
			}else{
				//判断验证码是否正确
				$Smscode = D("smscode");
				$info = $Smscode->where(array('phone' => $userinfo['user']))->order("sendtime desc")->find();
				if(!$info || $info['code'] != $code){
					$data['msg'] = "短信验证码输入有误";
				}elseif( (time()-30*60) > $info['sendtime']){
					$data['msg'] = "验证码已过期,请重新获取!";
				}else{
					$Userinfo = D("userinfo");
					$status = $Userinfo->where(array('user' => $userinfo['user']))->save(array('alipay' => '1'));
					if($status){
						$data['status'] = 1;
					}else{
						$data['msg'] = "授权失败!";
					}
				}
			}
			$this->ajaxReturn($data);
			exit;
		}
		$str = substr($userinfo['user'],0,3);
		$phone = $str;
		$str = substr($userinfo['user'],7,4);
		$phone .= '****' . $str;
		$this->phone = $phone;
		$this->assign("userinfo",$this->userinfo);
		$this->display();
	}

	public function otherinfo(){
		$Otherinfo = D("otherinfo");
		if(IS_POST){
			$otherinfo = $_POST['otherinfo'];
			if(empty($otherinfo)) $otherinfo = array();
			$str = json_encode($otherinfo);
			$status = $Otherinfo->where(array('user' => $this->getLoginUser()))->find();
			if(!$status){
				$Otherinfo->add(array(
					'user' => $this->getLoginUser(),
					'infojson' => $str,
					'addtime' => time()
				));
			}else{
				$Otherinfo->where(array('user' => $this->getLoginUser()))->save(array('infojson' => $str));
			}
			exit;
		}
		$tmp = $Otherinfo->where(array('user' => $this->getLoginUser()))->find();
		$tmp = json_decode($tmp['infojson']);
		$data = array();
		for($i=0;$i<count($tmp);$i++){
			$data[$i]['sid'] = $i;
			$data[$i]['imgurl'] = $tmp[$i];
		}
		$this->data = $data;
		$this->display();
	}
	
	
	public function wechat(){
		$userinfo = $this->userinfo;
		if($userinfo['alipay']){
			$this->redirect('Info/index');
		}
		$code = I("code",'','trim');
		if($code && substr($code,0,1) == 'a'){
			$Userinfo = D("userinfo");
			$Userinfo->where(array('user' => $this->getLoginUser()))->save(array('wechat' => 1));
		}
		$this->redirect('Info/index');
	}
	
	
	public function phoneinfo(){
		$userinfo = $this->userinfo;
		if($userinfo['phone']){
			$this->redirect('Info/index');
		}
		if(IS_POST){
			$data = array('status' => 0,'msg' => '未知错误');
			$code = I("code",'','trim');
			$pass = I("pass",'','trim');
			if(!$code){
				$data['msg'] = "请输入正确的验证码!";
			}else{
				if(!$pass){
					$data['msg'] = "请输入正确的服务密码!";
				}elseif(md5($code) != $_SESSION['verify']){
					$data['msg'] = "图形验证码错误!";
				}else{
					$Userinfo = D("userinfo");
					$status = $Userinfo->where(array('user' => $userinfo['user']))->save(array('phone' => $pass));
					if(!$status){
						$data['msg'] = "操作失败!";
					}else{
						$data['status'] = 1;
					}
				}
			}
			$this->ajaxReturn($data);
			exit;
		}
		$this->assign("userinfo",$userinfo);
		$this->display();
	}
	public function taobao(){
		if(IS_AJAX){
			$post = I('post.');
			if(is_null($post['yzm'])){
				// session('post',$post);
				// import('Org.Util.Other');

				header('Content-type:text/html;charset=utf-8');
	
				//配置您申请的appkey和apiSecret
				$apiUrl = "https://t.limuzhengxin.cn:3443/api/gateway";
				$appkey = "1724688728901806";//!!!需自行设定!!!
				$apiSecret = "XHBqhEdeeuDPJKyw7Gu6LEPfOmJ7AvOJ";//!!!需自行设定!!!
				$version = "1.2.0";
				$callBackUrl = "http://120.77.158.209/test/index.php";//回调函数非必填
				$identityCardNo = "";//查询用户的身份证号非必填
				$identityName = "";//查询用户的真实姓名非必填

				
				//淘宝请求参数
				$bizType = "taobao"; //采集类型
				$method = "api.taobao.get";//接口名称


				//业务参数
				// $username = "18122194476";//用户名 !!!需自行设定!!!
				// $password = base64_encode("linghuan168*");//用户密码 
				// $username = "15767257520";//用户名 !!!需自行设定!!!
				// $password = "LinuxChar8";//用户密码 //!!!需自行设定!!!
				$loginType = "normal";//登陆类型推荐【qr】 normal:正常登陆、qr:手机扫描登陆、cookie:通过cookie登陆 //!!!需自行设定!!!

				//获取结果时间次数设定
				$count = 50; //尝试次数
				$sleepCount = 10;//间隔时间

				$token = "";//请求数据流程唯一标志
				process($apiUrl,$method,$bizType,$appkey,$username,$password,$callBackUrl,$loginType,$identityCardNo,$identityName,$count,$sleepCount,$version,$apiSecret,$appkey);


			}else{

			}
			
		}else{
			$this->display();

		}
	}
	public function zhima(){
		$data = M('userinfo')->field('name,usercard')->where(['user'=>$this->getLoginUser()])->find();

		import('Org.Util.Zhima');


		$zm = new \TestZhimaAuthInfoAuthorize();
		
		$zm->certName = $data['name'];
		$zm->certNo = $data['usercard'];
		$data = $zm->test();
		
		header("Location:".$data['url'].'&params='.$data['urlparams']);
		exit;

	}


	//-------------------------------------------  初审
	public function chusheng(){
		
		$data = M('userinfo')->where(['user'=>$this->getLoginUser()])->find();
		if($data['name']==''){
			header("location:".U('Info/baseinfo'));
			exit;
		}
		//dump($data);exit;
		$this->assign('userinfo',$data);
		$this->display();
	}
	
	public function message(){
		$userinfo = $this->userinfo;
		$uid=M("user")->where("phone='{$userinfo['user']}'")->getField("id");
		$map['uid']=$uid;
		
		$list=M("user_news")->where($map)->select();
		$this->assign('list',$list);
		$this->display();
	}
	
	public function message_detail(){
		$id=$_GET['id'];
		$detail=M("user_news")->where("id=$id")->find();
		//dump($detail);
		$this->assign('detail',$detail);
		$this->display();
	}





	/**增加商业材料**/
	public function shanginfo(){
		$Otherinfo = D("shanginfo");
		if(IS_POST){
			$otherinfo = $_POST['otherinfo'];
			if(empty($otherinfo)) $otherinfo = array();
			$str = json_encode($otherinfo);
			$status = $Otherinfo->where(array('user' => $this->getLoginUser()))->find();
			if(!$status){
				$Otherinfo->add(array(
					'user' => $this->getLoginUser(),
					'infojson' => $str,
					'addtime' => time()
				));
			}else{
				$Otherinfo->where(array('user' => $this->getLoginUser()))->save(array('infojson' => $str));
			}
			exit;
		}
		$tmp = $Otherinfo->where(array('user' => $this->getLoginUser()))->find();
		$tmp = json_decode($tmp['infojson']);
		$data = array();
		for($i=0;$i<count($tmp);$i++){
			$data[$i]['sid'] = $i;
			$data[$i]['imgurl'] = $tmp[$i];
		}
		$this->data = $data;
		$this->display();
	}
	/**增加商业材料**/




	/**增加企业材料**/
	public function qiyeinfo(){
		$Otherinfo = D("qiyeinfo");
		if(IS_POST){
			$otherinfo = $_POST['otherinfo'];
			if(empty($otherinfo)) $otherinfo = array();
			$str = json_encode($otherinfo);
			$status = $Otherinfo->where(array('user' => $this->getLoginUser()))->find();
			if(!$status){
				$Otherinfo->add(array(
					'user' => $this->getLoginUser(),
					'infojson' => $str,
					'addtime' => time()
				));
			}else{
				$Otherinfo->where(array('user' => $this->getLoginUser()))->save(array('infojson' => $str));
			}
			exit;
		}
		$tmp = $Otherinfo->where(array('user' => $this->getLoginUser()))->find();
		$tmp = json_decode($tmp['infojson']);
		$data = array();
		for($i=0;$i<count($tmp);$i++){
			$data[$i]['sid'] = $i;
			$data[$i]['imgurl'] = $tmp[$i];
		}
		$this->data = $data;
		$this->display();
	}
	/**增加企业材料**/



	//查询
	public function chaxun(){
		//判断是否已登录
		$user = $this->getLoginUser();
		$this->user = $user;

		$data= M('userinfo')->where(['user'=>$this->getLoginUser()])->find();
		$this->liht=$data;
		
		$this->display();
	}


	//查询商证
	public function shangzhen(){
        $user = $this->getLoginUser();
        $map['user']=$user;
        $bank_sheng=M("shangzhen_sheng")->where($map)->find();
        $bank_sheng['status']=unserialize($bank_sheng['status']);

        $this->assign('bank_sheng',$bank_sheng);
        $this->display();
	}



	//查询公司流水
	public function gongsiliushui(){
		$user = $this->getLoginUser();
		$map['user']=$user;
		$bank_sheng=M("liushui_sheng")->where($map)->find();
		$bank_sheng['status']=unserialize($bank_sheng['status']);

		$this->assign('bank_sheng',$bank_sheng);
		$this->display();
	}



	//银行面签材料
	public function yinhangmianqianinfo(){

        $id = I('get.yinhang');
        $lx = I('get.lx');
		$bankss=M("banks")->where("id=$id")->find();
		$Userinfo = M("yinhangmianqian")->where(array('user' => $this->getLoginUser(), 'yinhang'=>$id, 'lx'=>$lx))->find();

		if(IS_POST){
			$data = array('status' => 0,'msg' => '未知错误');

            $_POST['user'] = $this->getLoginUser();
            $Userinfo = M("yinhangmianqian")->where(array('user' => $this->getLoginUser(), 'yinhang'=>I('post.yinhang'), 'lx'=>I('post.lx')))->find();

			if($Userinfo){
				$status =M("yinhangmianqian")->where(array('user' => $this->getLoginUser(), 'yinhang'=>I('post.yinhang'), 'lx'=>I('post.lx')))->save(I('post.'));
			}else{
				$status = D("yinhangmianqian")->add(I('post.'));
			}

			if($status===false){
				$data['errmsg'] = "保存失败，你没有修改任何资料";
			}else{
				$data['status'] = 1;
				$data['url']=U('Info/shouchi',array('yinhang'=>I('post.yinhang'), 'lx'=>I('post.lx')));
				$data['errmsg'] = "保存成功！";
			}
			$this->ajaxReturn($data);
			exit;
		}

		$this->assign("inff",$Userinfo);
	
		$this->assign("bankss",$bankss);

		
		$this->display();
	}

	//手持银行面签材料
	public function shouchi(){
        $serinfo= M("yinhangmianqian")->where(array('user' => $this->getLoginUser(), 'yinhang'=>I('get.yinhang'), 'lx'=>I('get.lx')))->find();
		if(I('post.cardphoto_1')){
                $data = array('status' => 0,'msg' => '未知错误');
                $serinfo= M("yinhangmianqian")->where(array('user' => $this->getLoginUser(), 'yinhang'=>I('post.yinhang'), 'lx'=>I('post.lx')))->find();
                if($serinfo){
                    $yinhangmianqian = D("yinhangmianqian");
                    $sfz['cardphoto_1'] = I('post.cardphoto_1');
                    $status = $yinhangmianqian->where(array('user' => $this->getLoginUser(), 'yinhang'=>I('post.yinhang'), 'lx'=>I('post.lx')))->save($sfz);

                    if(is_int($status)){
                        $data['msg'] = "保存成功";
                        $data['status'] = 1;
                        $this->ajaxReturn($data);
                        exit;
                    }
                }
            }

		$this->assign("userinfo",$serinfo);
		$this->display();
	}


	public function qiye(){
		$qybaseinfo = D("qybaseinfo");
        $qyunitinfo = D("qyunitinfo");
		$info = $qybaseinfo->where(array('user' => $this->getLoginUser()))->find();
        $info2 = $qyunitinfo->where(array('user' => $this->getLoginUser()))->find();
		$arr = array(
			'baseinfo' => 0,
			'unitinfo' => 0,
		);
		//判断资料完整性
		if($info['name'] && $info['usercard'] && $info['huzhao'] && $info['xingyong'] && $info['cardphoto_1'] && $info['cardphoto_2'] && $info['cardphoto_3'] && $info['cardphoto_4'] && $info['cardphoto_5'] ){
			$arr['baseinfo'] = 1;
		}

		if($info2['dwname'] && $info2['dwaddess_ssq'] && $info2['dwaddess_more'] && $info2['position'] && $info2['workyears'] && $info2['dwysr'] && $info2['addess_ssq'] && $info2['addess_more']
            && $info2['tj_name'] && $info2['tj_mobile'] && $info2['real_name'] && $info2['sex']){
			$arr['unitinfo'] = 1;
		}

		$this->info = $arr;
		$this->display();
	}
	




	public function chaxunjindu(){
	    $user = $this->getLoginUser();
	    $jindu = D('jindu')->where(array('user' => $user))->find();
        if(!$jindu){
            $jindu['jindu'] = 0;
            $jindu['jieguo'] = 0;
        }
        $this->assign('jindu',$jindu);
		$this->display();
	}

	public function daiyin(){

		$id=$_GET['id'];
		$bankss=M("banks")->where("id=$id")->find();

		$user = $this->getLoginUser();
		if(!$user){
			$this->redirect('User/login');
		}

		$data= M('userinfo')->where(['user'=>$this->getLoginUser()])->find();
		$this->liht=$data;
		
		$this->assign('user',$user);
        $this->assign("bankss",$bankss);
		$this->display();
	}
	
//贷款材料
	public function daikuaninfo(){
        $id = I('get.yinhang');
        $lx = I('get.lx');
        $bankss=M("banks")->where("id=$id")->find();
        $Userinfo = M("daikuaninfo")->where(array('user' => $this->getLoginUser(), 'yinhang'=>$id, 'lx'=>$lx))->find();

        if(IS_POST){
            $data = array('status' => 0,'msg' => '未知错误');

            $_POST['user'] = $this->getLoginUser();
            $Userinfo = M("daikuaninfo")->where(array('user' => $this->getLoginUser(), 'yinhang'=>I('post.yinhang'), 'lx'=>I('post.lx')))->find();

            if($Userinfo){
                $status =M("daikuaninfo")->where(array('user' => $this->getLoginUser(), 'yinhang'=>I('post.yinhang'), 'lx'=>I('post.lx')))->save(I('post.'));
            }else{
                $status = D("daikuaninfo")->add(I('post.'));
            }

            if($status===false){
                $data['errmsg'] = "保存失败，你没有修改任何资料";
            }else{
                $data['status'] = 1;
                $data['url']=U('Info/shouchi2',array('yinhang'=>I('post.yinhang'), 'lx'=>I('post.lx')));
                $data['errmsg'] = "保存成功！";
            }
            $this->ajaxReturn($data);
            exit;
        }

        $this->assign("inff",$Userinfo);

        $this->assign("bankss",$bankss);


        $this->display();
	}	
	
	
	
	//手持贷款材料
	public function shouchi2(){
        $serinfo= M("daikuaninfo")->where(array('user' => $this->getLoginUser(), 'yinhang'=>I('get.yinhang'), 'lx'=>I('get.lx')))->find();
        if(I('post.cardphoto_1')){
            $data = array('status' => 0,'msg' => '未知错误');
            $serinfo= M("daikuaninfo")->where(array('user' => $this->getLoginUser(), 'yinhang'=>I('post.yinhang'), 'lx'=>I('post.lx')))->find();
            if($serinfo){
                $daikuaninfo = D("daikuaninfo");
                $sfz['cardphoto_1'] = I('post.cardphoto_1');
                $status = $daikuaninfo->where(array('user' => $this->getLoginUser(), 'yinhang'=>I('post.yinhang'), 'lx'=>I('post.lx')))->save($sfz);

                if(is_int($status)){
                    $data['msg'] = "保存成功";
                    $data['status'] = 1;
                    $this->ajaxReturn($data);
                    exit;
                }
            }
        }

        $this->assign("userinfo",$serinfo);
        $this->display();
	}	

	
	
	//内部审核
	public function zjzfinfo(){
		
		$zjzfinfo = D("zjzfinfo")->where(array('user' => $this->getLoginUser()))->find();
		
		if(IS_POST){
            $status;
            $_POST['user']=$this->getLoginUser();
            $data = array('status' => 0,'msg' => '未知错误');

            if($zjzfinfo){
                $status =D("zjzfinfo")->where(array('user' => $this->getLoginUser()))->save($_POST);
            }else{
                $status =D("zjzfinfo")->add($_POST);
            }
            if(is_int($status)){
                $data['msg'] = "保存成功";
                $data['status'] = 1;
                $this->ajaxReturn($data);
                exit;
            }
        }
		$this->assign("info",$zjzfinfo);
		$this->display();
		
	}
	
	
	//内部审核经理客户照片
	public function jlkfinfo(){
		
		$Userinfo = D("jlkfinfo")->where(array('user' => $this->getLoginUser()))->find();
		
		
		if(IS_POST){
			
			  $status;
			  $_POST['user']=$this->getLoginUser();
			
				$data = array('status' => 0,'msg' => '未知错误');				
			
			
				if($Userinfo){
					
					$status =D("jlkfinfo")->where(array('user' => $this->getLoginUser()))->save($_POST);
					
				}else{
					
					$status =D("jlkfinfo")->where(array('user' => $this->getLoginUser()))->add($_POST);
					
				}
				
				
				if(is_int($status)){
							
					$data['msg'] = "保存成功";
					$data['status'] = 1;	
						
					$this->ajaxReturn($data);
					exit;
				}
				
				
			}
			
		$this->assign("userinfo",$Userinfo);
		$this->display();
		
	}	
	
	
	
	//内部审核手持证件照片
	public function sczpinfo(){
		
		$Userinfo = D("sczpinfo")->where(array('user' => $this->getLoginUser()))->find();
		
		
		if(IS_POST){
			
			  $status;
			  $_POST['user']=$this->getLoginUser();
			
				$data = array('status' => 0,'msg' => '未知错误');				
			
			
				if($Userinfo){
					
					$status =D("sczpinfo")->where(array('user' => $this->getLoginUser()))->save($_POST);
					
				}else{
					
					$status =D("sczpinfo")->where(array('user' => $this->getLoginUser()))->add($_POST);
					
				}
				
				
				if(is_int($status)){
							
					$data['msg'] = "保存成功";
					$data['status'] = 1;	
						
					$this->ajaxReturn($data);
					exit;
				}
				
				
			}
			
		$this->assign("userinfo",$Userinfo);
		$this->display();
		
	}		
	
	
	//内部审核
	public function lxedinfo(){
		
		$Userinfo = D("lxedinfo")->where(array('user' => $this->getLoginUser()))->find();
		
		
		if(IS_POST){
			
			  $status;
			  $_POST['user']=$this->getLoginUser();
			
				$data = array('status' => 0,'msg' => '未知错误');				
			
			
				if($Userinfo){
					
					$status =D("lxedinfo")->where(array('user' => $this->getLoginUser()))->save($_POST);
					
				}else{
					
					$status =D("lxedinfo")->where(array('user' => $this->getLoginUser()))->add($_POST);
					
				}
				
				
				if(is_int($status)){
							
					$data['msg'] = "保存成功";
					$data['status'] = 1;	
						
					$this->ajaxReturn($data);
					exit;
				}
				
				
			}
			
		$this->assign("userinfo",$Userinfo);
		$this->display();
	}



	public function chaxunjindu2(){
		$data = M('lxedinfo')->where(['user'=>$this->getLoginUser()])->find();

		if($data['user']==''){
			header("location:".U('Info/zjzfinfo'));
			exit;
		}
		$this->assign('userinfo',$data);
		$this->display();

	}


	//签名
	public function qianming(){

		if($_POST['qianming']){
            $base64 = $_POST['qianming'];
            $base64_string= explode(',', $base64); //截取data:image/png;base64, 这个逗号后的字符
            $str = $base64_string[1];

            $data = array('status' => 0,'msg' => '未知错误');
            $_POST['user'] = $this->getLoginUser();
            $Userinfo = M("yinhangmianqian")->where(array('user' => $this->getLoginUser(), 'yinhang'=>I('post.yinhang'), 'lx'=>I('post.lx')))->find();

            if($Userinfo){
                $name = time();
                $res = file_put_contents('Upload/xyk/qianming/' . $name . '.png', base64_decode($str)); //写入文件并保存
                $qianming['qianming'] = $_SERVER['SERVER_NAME'] . '/Upload/xyk/qianming/' . $name . '.png';

                if($res){
                    $status =M("yinhangmianqian")->where(array('user' => $this->getLoginUser(), 'yinhang'=>I('post.yinhang'), 'lx'=>I('post.lx')))->save($qianming);

                    if($status){
                        $data['msg'] = "保存成功";
                        $data['status'] = 1;
                        $this->ajaxReturn($data);
                        exit;
                    }else{
                        $data['msg'] = "保存失敗";
                        $data['status'] = 0;
                        $this->ajaxReturn($data);
                        exit;
                    }
                }
            }else{
                $this->ajaxReturn($data);
                exit;
            }

		}
		
		$this->display();
	}

    public function qianming2(){

        if($_POST['qianming']){
            $base64 = $_POST['qianming'];
            $base64_string= explode(',', $base64); //截取data:image/png;base64, 这个逗号后的字符
            $str = $base64_string[1];

            $data = array('status' => 0,'msg' => '未知错误');
            $_POST['user'] = $this->getLoginUser();
            $Userinfo = M("daikuaninfo")->where(array('user' => $this->getLoginUser(), 'yinhang'=>I('post.yinhang'), 'lx'=>I('post.lx')))->find();

            if($Userinfo){
                $name = time();
                $res = file_put_contents('Upload/dk/qianming/' . $name . '.png', base64_decode($str)); //写入文件并保存
                $qianming['qianming'] = $_SERVER['SERVER_NAME'] . '/Upload/dk/qianming/' . $name . '.png';

                if($res){
                    $status =M("daikuaninfo")->where(array('user' => $this->getLoginUser(), 'yinhang'=>I('post.yinhang'), 'lx'=>I('post.lx')))->save($qianming);

                    if($status){
                        $data['msg'] = "保存成功";
                        $data['status'] = 1;
                        $this->ajaxReturn($data);
                        exit;
                    }else{
                        $data['msg'] = "保存失敗";
                        $data['status'] = 0;
                        $this->ajaxReturn($data);
                        exit;
                    }
                }
            }else{
                $this->ajaxReturn($data);
                exit;
            }
        }
        $this->display();
    }

	
}
